Temperature and humidity are one of the essential parameters of environment for various projects like greenhouse, home automation, weather station or other various industrial automation. Sometime we also need to find feel temperature or apparent temperature that we feel and it is called Heat Index. Heat Index can be defined as an index which accounts both air temperature and relative humidity of an environment. In this article we are going to build a temperature, humidity and heat index meter using arduino and DHT11.
Circuit of Temperature, Humidity and Heat Index Meter
The circuit shown in figure 1 is build around DHT11, I2C LCD and Seeeduino Nano (Customize version of arduino nano). Let’s see the connection of all these components. LCD is connected in I2C mode i.e. data pin (SDA) of LCD is connected to SDA pin of arduino nano (A4) where clock pin (SCL) of LCD is connected to SCL pin of arduino nano (A5). Power pins of LCD i.e. Vcc and GND pin is connected to +5V and GND of Arduino nano.
DHT11 module pin have three pin two for power rails and one for data pin. Power pins i.e. Vcc and GND is connected to +5V and GND of arduino nano as shown in circuit diagram. Dout or data pin is connected to arduino digital pin (D2) but you can connect to any other pin as per your requirement.
Software code:
Software code for Temperature, Humidity and Heat Index Meter using Arduino is written in C++ programming and is compiled using Arduino IDE. Let’s understand the program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
#include <DHT.h> //Library for DHT Sensor #include "rgb_lcd.h" //Library for RGB I2C LCD #define DHTPIN 2 //Arduino Digital pin connected to Dout of DHT11 #define DHTTYPE DHT11 //Type of DHT Sensor (DHT11) DHT dht(DHTPIN, DHTTYPE); rgb_lcd lcd; const long eventTime_DHT = 3000; //Update Time in mili Second unsigned long previousTime_DHT = 0; const int colorR = 255; //Max. Value of Red color for background color of LCD const int colorG = 0; // Min. value of Green color for background color of LCD const int colorB = 0; // Min. value of Blue color for background color of LCD void setup() { lcd.begin(16, 2); //initialize the LCD lcd.setRGB(colorR, colorG, colorB); dht.begin(); //Initialize the DHT Sensor } void loop(){ unsigned long currentTime = millis(); //assigning the value of mills if(currentTime-previousTime_DHT >= eventTime_DHT) //Check for delay time { lcd.clear(); float FHI; float RH = dht.readHumidity(); // getting the value of relative humidity float t = dht.readTemperature(); // getting the value of temp. in Celsius float T = dht.readTemperature(true); // getting the value of temp. in Fahrenheit //formula for calculating Heat index float HI = -42.379 + 2.04901523*T + 10.14333127*RH - 0.22475541*T*RH - 0.00683783*T*T - 0.05481717*RH*RH + 0.00122874*T*T*RH + 0.00085282*T*RH*RH - 0.00000199*T*T*RH*RH; float Adj1 = ((13-RH/4))*sqrt((17-fabs(T-95.0))/17); float Adj2 = ((RH-85)/10)*((87-T)/5); //formula for calculating Heat index if Humidity < 13% and temp. is //between 80 degree Fahrenheit and 112 degree Fahrenheit. if(RH < 13 && T > 80 && T < 112) { HI = HI + Adj1; } //formula for calculating Heat index if Humidity > 13% and temp. is //between 80 degree Fahrenheit and 87 degree Fahrenheit. if(RH > 85 || T < 87 || T > 80) { HI = HI + Adj2; } //If Heat index is greater then 80 Fahrenheit if(HI > 80) { HI = 0.5*(T + 61.0 + ((T-68.0)*1.2) + (RH*0.094)); } lcd.setCursor(0,0); lcd.print("Temp:"); lcd.setCursor(5,0); lcd.print(T); lcd.setCursor(9,0); lcd.print("F"); lcd.setCursor(0,1); lcd.print("Hum:"); lcd.setCursor(4,1); lcd.print(RH); lcd.setCursor(9,1); lcd.print("%"); lcd.setCursor(11,0); lcd.print("H.Ind"); lcd.setCursor(11,1); lcd.print(HI); lcd.setCursor(15,1); lcd.print("F"); previousTime_DHT = currentTime; } } |